<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/css/backStageBase.css}">
    <style>
        .layui-table img{
            max-width: 200px !important;
        }
        .layui-table-cell {
            height: auto !important;

        }
    </style>
</head>
<body class="layui-layout-body">
    <div id="backstage" class="layui-layout layui-layout-admin">
        <div class="layui-header layui-bg-blue" >
            <div class="layui-logo">青木良品</div>
            <ul class="layui-nav  layui-layout-left" lay-filter="">
                <li class="layui-nav-item">商品管理</li>
            </ul>
            <ul class="layui-nav layui-layout-right layui-bg-blue">
                <li class="layui-nav-item" th:text="'欢迎你，'+${session.user.name}">
                </li>
                <li class="layui-nav-item"><a href="/mall/user/logout.do">退出</a></li>
            </ul>
        </div>

        <div class="layui-side layui-bg-gray">
            <ul class="layui-nav layui-nav-tree layui-bg-blue" lay-filter="test">
                <!-- 侧边导航: <ul class="layui-nav layui-nav-tree layui-nav-side"> -->
                <li class="layui-nav-item layui-nav-itemed"><a th:href="@{/admin/product/toList.html}">商品管理</a></li>
                <li class="layui-nav-item"><a th:href="@{/admin/activity/toList.html}">活动管理</a></li>
                <li class="layui-nav-item"><a th:href="@{/admin/order/toList.html}">订单管理</a></li>
                <li class="layui-nav-item"><a th:href="@{/admin/user/toList.html}">用户管理</a></li>
            </ul>
        </div>
        <div class="layui-body" style="overflow: hidden;height: 650px">
            <div class="layui-tab layui-tab-card">
                <ul class="layui-tab-title">
                    <li class="layui-this">修改信息</li>
                </ul>
                <div class="layui-tab-content"  style="height: 650px;">
                    <div class="layui-tab-item layui-show">
                        <form id="updatainfo" class="layui-form" method="post" action="updata.do">
                            <div class="layui-form-item" style="display: none">
                                <label class="layui-form-label">用户ID</label>
                                <div class="layui-input-block" style="width: 300px;">
                                    <input type="text" name="id" required  lay-verify="required" autocomplete="off" class="layui-input" th:value="${user.id}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">用户名称</label>
                                <div class="layui-input-block" style="width: 300px;">
                                    <input type="text" name="name" required  lay-verify="required" placeholder="请输入用户名称" autocomplete="off" class="layui-input" th:value="${user.name}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">用户密码</label>
                                <div class="layui-input-block" style="width: 300px;">
                                    <input type="text" name="password" required  lay-verify="required" placeholder="请输入用户密码" autocomplete="off" class="layui-input" th:value="${user.password}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">联系电话</label>
                                <div class="layui-input-block" style="width: 300px;">
                                    <input type="text" name="phone" required  lay-verify="required|phone" placeholder="请输入联系电话" autocomplete="off" class="layui-input" th:value="${user.telephone}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">电子邮箱</label>
                                <div class="layui-input-block" style="width: 300px;">
                                    <input type="text" name="email" required  lay-verify="required|email" placeholder="请输入电子邮箱" autocomplete="off" class="layui-input" th:value="${user.email}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">收货地址</label>
                                <div class="layui-input-block" style="width: 300px;">
                                    <input type="text" name="addr" required  lay-verify="required" placeholder="请输入收货地址" autocomplete="off" class="layui-input" th:value="${user.address1}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script th:src="@{/js/jqurey.js}"></script>
<script th:src="@{/layui/layui.js}"></script>
<script type="text/javascript">
    var pageIndex=1
    layui.use(['element','form','table','layer'], function(){
        var element = layui.element;
        var form = layui.form;
        var layer = layui.layer;
        // 表格渲染
        var table = layui.table;
    });
    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
            console.log(variable+':'+pair[1])
        }
        return(false);
    }

    $(function () {
        //getData(1)
    })
    function updata() {
        var data = {};
        var t = $('#updatainfo').serializeArray();
        $.each(t, function () {
            data[this.name] = this.value;
        });
        data["id"]=getQueryVariable(id)
        alert(data)
        $.ajax({
            //请求方式
            type : "POST",
            //请求的媒体类型
            contentType: "application/json;charset=UTF-8",
            //请求地址
            url : "list.do",
            // 数据
            data: JSON.stringify(data),
            //请求成功
            success : function(data) {

            },
            error : function (e) {
                
            }
        });
    }
</script>
</html>